<%--                                                                       --%>
<%-- Copyright (c) 2003 BroadVision, Inc.  All rights reserved.            --%>
<%--                                                                       --%>
<%-- This software is copyrighted. Under the copyright laws, this software --%>
<%-- may not be copied, in whole or in part, without prior written consent --%>
<%-- of BroadVision, Inc. or its assignees. This software is provided      --%>
<%-- under the terms of a license between BroadVision and the recipient,   --%>
<%-- and its use is subject to the terms of that license.                  --%>
<%--                                                                       --%>
<%-- This software may be protected by one or more U.S. and International  --%>
<%-- patents.  Certain applications of BroadVision One-To-One software are --%>
<%-- covered by U.S. patent 5,710,887.                                     --%>
<%--                                                                       --%>
<%-- TRADEMARKS: BroadVision and BroadVision One-To-One are registered     --%>
<%-- trademarks of BroadVision, Inc., in the United States and the         --%>
<%-- European Community, and are trademarks of BroadVision, Inc., in other --%>
<%-- countries.  The BroadVision logo, is a trademark of BroadVision,      --%>
<%-- Inc., in the United States and other countries. Additionally, IONA    --%>
<%-- and Orbix are trademarks of IONA Technologies, Ltd.  RSA, MD5, and    --%>
<%-- RC2 are trademarks of RSA Data Security, Inc.                         --%>
<%--                                                                       --%>

<%@ page import = "java.util.*, java.net.*,
  com.broadvision.ssp.client.SelfServiceProcess,
  com.broadvision.ssp.client.*,
  com.broadvision.ssp.client.workflow.*,
  com.broadvision.ssp.common.*"
%>

<%@ taglib uri="/WEB-INF/c.tld" prefix="c" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>

<SCRIPT language="javascript">

  function doReset(myform) {
    myform.action = '<c:url value="/bp/processTaskEdit.do"/>';
    myform.submit();
  }

  function doCancel(myform) {
    myform.action = '<c:url value="/bp/processTaskView.do"/>';
    myform.submit();
  }

  function doSave(myform) {
    if (<bean:write name="processTaskView" property="type"/> != 12) {
      if (myform.estimatedCycleTime <= 0) {
        alert('<bean:message key="bp.process.error.invalidCycleTime" bundle="bp.messages"/>');
        return;
      }
    }
    if (validateProcessTaskForm(myform) == false) {
      return;
    }
    myform.forwardAction.value="/bp/processTaskView.do";
    myform.action = '<c:url value="/bp/processTaskEditSave.do"/>';
    myform.submit();
  }

</SCRIPT>

<% 
  java.util.HashMap map = new java.util.HashMap();
  String procOid = request.getParameter("processOid"); 
  String taskNumber = request.getParameter("number"); 
  if (procOid != null && procOid.length() > 0 && taskNumber != null && taskNumber.length() > 0) {
    map.put("processOid", procOid);
    map.put("number", taskNumber);
  }
  else {
    map.put("processOid", "-1");
    map.put("number", "-1");
  }
  pageContext.setAttribute("pagetabParam", map, PageContext.PAGE_SCOPE);
%>

<html:javascript formName="bpProcessTaskForm"/>
<html:form action="/bp/processTaskEditSave.do">
<html:hidden name="bpProcessTaskForm" property="processOid"/>
<html:hidden name="bpProcessTaskForm" property="number"/>
<input type="Hidden" name="forwardAction"/>
<table class="zoneFive" width="100%" border="0" cellspacing="0" cellpadding="0" summary="content area">
  <tr>
    <td valign="top" width="100%">
      <div class="pageTitle"><bean:write name="processTaskView" property="processName"/></div>
      <div class="errorMessage"><html:errors bundle="bp.messages"/></div>
      <%@include file="/mc/common/pagetab.jsp" %>
      <div class="breadcrumb">
        <logic:present name="processSubprocessPath" scope="session">
          <logic:greaterThan name="processSubprocessPath" property="processOid" value="0">
            <bean:write name="processSubprocessPath" property="processName"/>
            <logic:iterate id="subprocess" name="processSubprocessPath" property="subprocesses" indexId="i">
              &nbsp;<bean:message key="bp.process.taskSeparator" bundle="bp.messages"/>&nbsp;
              <bean:write name="subprocess" property="number"/>:
              <bean:write name="subprocess" property="friendlyName"/>
              &nbsp;<bean:message key="bp.process.taskSeparator" bundle="bp.messages"/>&nbsp;
              <bean:write name="subprocess" property="subprocessName"/>
            </logic:iterate>
          </logic:greaterThan>
        </logic:present>
        <logic:present name="processSubprocessPath" scope="session">
          <logic:equal name="processSubprocessPath" property="processOid" value="0">
            <bean:write name="processTaskView" property="processName"/>
          </logic:equal>
        </logic:present>
        <logic:notPresent name="processSubprocessPath" scope="session">
          <bean:write name="processTaskView" property="processName"/>
        </logic:notPresent>
        &nbsp;<bean:message key="bp.process.taskSeparator" bundle="bp.messages"/>&nbsp;
        <bean:write name="bpProcessTaskForm" property="number"/>:
        <bean:write name="processTaskView" property="friendlyName"/>
      </div>
      <div class="pageSubtitle">
        <span class="left"><bean:message key="bp.process.processTask.information" bundle="bp.messages"/></span>
        <span class="right">&nbsp;</span>
      </div> 
      <table class="labelForm" width="100%" border="0" cellspacing="0" cellpadding="0" summary="Process summary">
        <tr> 
          <td class="label" width="30%"><bean:message key="bp.process.processTask.stepName" bundle="bp.messages"/></td>
          <td class="labelField" width="70%"><bean:write name="processTaskView" property="friendlyName"/></td>
        </tr>
        <tr> 
          <td class="label" width="30%"><bean:message key="bp.process.processTask.documentation" bundle="bp.messages"/></td>
          <td class="labelField" width="70%">
            <html:textarea name="bpProcessTaskForm" property="documentation" cols="31" rows="4"/>
          </td>
        </tr>
        <tr> 
          <td class="label" width="30%"><bean:message key="bp.process.processTask.stepType" bundle="bp.messages"/></td>
          <td class="labelField" width="70%">
            <logic:equal name="processTaskView" property="type" value="0">
              <img src="<%=request.getContextPath()%>/bp/images/icons/flow.gif" border="0" alt="<bean:message key="bp.process.processSteps.taskType.webflow" bundle="bp.messages"/>" title="<bean:message key="bp.process.processSteps.taskType.webflow" bundle="bp.messages"/>" align="adsmiddle">
              <bean:message key="bp.process.processSteps.taskType.webflow" bundle="bp.messages"/>
            </logic:equal>
            <logic:equal name="processTaskView" property="type" value="1">
              <img src="<%=request.getContextPath()%>/bp/images/icons/aa.gif" border="0" alt="<bean:message key="bp.process.processSteps.taskType.aa" bundle="bp.messages"/>" title="<bean:message key="bp.process.processSteps.taskType.aa" bundle="bp.messages"/>" align="adsmiddle">
              <bean:message key="bp.process.processSteps.taskType.aa" bundle="bp.messages"/>
            </logic:equal>
            <logic:equal name="processTaskView" property="type" value="2">
              <img src="<%=request.getContextPath()%>/bp/images/icons/manual.gif" border="0" alt="<bean:message key="bp.process.processSteps.taskType.manual" bundle="bp.messages"/>" title="<bean:message key="bp.process.processSteps.taskType.manual" bundle="bp.messages"/>" align="adsmiddle">
              <bean:message key="bp.process.processSteps.taskType.manual" bundle="bp.messages"/>
            </logic:equal>
            <logic:equal name="processTaskView" property="type" value="3">
              <img src="<%=request.getContextPath()%>/bp/images/icons/milestone.gif" border="0" alt="<bean:message key="bp.process.processSteps.taskType.milestone" bundle="bp.messages"/>" title="<bean:message key="bp.process.processSteps.taskType.milestone" bundle="bp.messages"/>" align="adsmiddle">
              <bean:message key="bp.process.processSteps.taskType.milestone" bundle="bp.messages"/>
            </logic:equal>
            <logic:equal name="processTaskView" property="type" value="4">
              <img src="<%=request.getContextPath()%>/bp/images/icons/beginning.gif" border="0" alt="<bean:message key="bp.process.processSteps.taskType.start" bundle="bp.messages"/>" title="<bean:message key="bp.process.processSteps.taskType.start" bundle="bp.messages"/>" align="adsmiddle">
              <bean:message key="bp.process.processSteps.taskType.start" bundle="bp.messages"/>
            </logic:equal>
            <logic:equal name="processTaskView" property="type" value="5">
              <img src="<%=request.getContextPath()%>/bp/images/icons/ending.gif" border="0" alt="<bean:message key="bp.process.processSteps.taskType.end" bundle="bp.messages"/>" title="<bean:message key="bp.process.processSteps.taskType.end" bundle="bp.messages"/>" align="adsmiddle">
              <bean:message key="bp.process.processSteps.taskType.end" bundle="bp.messages"/>
            </logic:equal>
            <logic:equal name="processTaskView" property="type" value="6">
              <img src="<%=request.getContextPath()%>/bp/images/icons/subprocess.gif" border="0" alt="<bean:message key="bp.process.processSteps.taskType.subworkflow" bundle="bp.messages"/>" title="<bean:message key="bp.process.processSteps.taskType.subworkflow" bundle="bp.messages"/>" align="adsmiddle">
              <bean:message key="bp.process.processSteps.taskType.subworkflow" bundle="bp.messages"/>
            </logic:equal>
            <logic:equal name="processTaskView" property="type" value="7">
              <img src="<%=request.getContextPath()%>/bp/images/icons/notification.gif" border="0" alt="<bean:message key="bp.process.processSteps.taskType.notification" bundle="bp.messages"/>" title="<bean:message key="bp.process.processSteps.taskType.notification" bundle="bp.messages"/>" align="adsmiddle">
              <bean:message key="bp.process.processSteps.taskType.notification" bundle="bp.messages"/>
            </logic:equal>
            <logic:equal name="processTaskView" property="type" value="8">
              <img src="<%=request.getContextPath()%>/bp/images/icons/cabinet.gif" border="0" alt="<bean:message key="bp.process.processSteps.taskType.cabinet" bundle="bp.messages"/>" title="<bean:message key="bp.process.processSteps.taskType.cabinet" bundle="bp.messages"/>" align="adsmiddle">
              <bean:message key="bp.process.processSteps.taskType.cabinet" bundle="bp.messages"/>
            </logic:equal>
            <logic:equal name="processTaskView" property="type" value="9">
              <img src="<%=request.getContextPath()%>/bp/images/icons/collaboration.gif" border="0" alt="<bean:message key="bp.process.processSteps.taskType.collaboration" bundle="bp.messages"/>" title="<bean:message key="bp.process.processSteps.taskType.collaboration" bundle="bp.messages"/>" align="adsmiddle">
              <bean:message key="bp.process.processSteps.taskType.collaboration" bundle="bp.messages"/>
            </logic:equal>
            <logic:equal name="processTaskView" property="type" value="10">
              <img src="<%=request.getContextPath()%>/bp/images/icons/policy.gif" border="0" alt="<bean:message key="bp.process.processSteps.taskType.policy" bundle="bp.messages"/>" title="<bean:message key="bp.process.processSteps.taskType.policy" bundle="bp.messages"/>" align="adsmiddle">
              <bean:message key="bp.process.processSteps.taskType.policy" bundle="bp.messages"/>
            </logic:equal>
            <logic:equal name="processTaskView" property="type" value="11">
              <img src="<%=request.getContextPath()%>/bp/images/icons/form.gif" border="0" alt="<bean:message key="bp.process.processSteps.taskType.form" bundle="bp.messages"/>" title="<bean:message key="bp.process.processSteps.taskType.form" bundle="bp.messages"/>" align="adsmiddle">
              <bean:message key="bp.process.processSteps.taskType.form" bundle="bp.messages"/>
            </logic:equal>
            <logic:equal name="processTaskView" property="type" value="12">
              <img src="<%=request.getContextPath()%>/bp/images/icons/timing.gif" border="0" alt="<bean:message key="bp.process.processSteps.taskType.timing" bundle="bp.messages"/>" title="<bean:message key="bp.process.processSteps.taskType.timing" bundle="bp.messages"/>" align="adsmiddle">
              <bean:message key="bp.process.processSteps.taskType.timing" bundle="bp.messages"/>
            </logic:equal>
            <logic:equal name="processTaskView" property="type" value="13">
              <img src="<%=request.getContextPath()%>/bp/images/icons/decision.gif" border="0" alt="<bean:message key="bp.process.processSteps.taskType.decision" bundle="bp.messages"/>" title="<bean:message key="bp.process.processSteps.taskType.decision" bundle="bp.messages"/>" align="adsmiddle">
              <bean:message key="bp.process.processSteps.taskType.decision" bundle="bp.messages"/>
            </logic:equal>
          </td>
        </tr>
        <tr> 
          <td class="label" width="30%"><bean:message key="bp.process.processTask.performer" bundle="bp.messages"/></td>
          <td class="labelField" width="70%">
            <logic:equal name="processTaskView" property="performer" value="LaunchUser">
    	    		<bean:message key="bp.process.processInstanceTaskDetail.LaunchUser" bundle="bp.messages"/>
            </logic:equal>
            <logic:notEqual name="processTaskView" property="performer" value="LaunchUser">
              <bean:write name="processTaskView" property="performer"/>
            </logic:notEqual>
          </td>
        </tr>
        <tr> 
          <td class="label" width="30%"><bean:message key="bp.process.processTask.assignmentTechnique" bundle="bp.messages"/></td>
          <td class="labelField" width="70%">
            <logic:equal name="processTaskView" property="assignmentTechnique" value="0">
              <bean:message key="bp.process.performerType.userPerformer" bundle="bp.messages"/>
            </logic:equal>
            <logic:equal name="processTaskView" property="assignmentTechnique" value="1">
              <bean:message key="bp.process.performerType.actorFunction" bundle="bp.messages"/>
            </logic:equal>
            <logic:equal name="processTaskView" property="assignmentTechnique" value="2">
              <bean:message key="bp.process.performerType.groupAnyPerformer" bundle="bp.messages"/>
            </logic:equal>
            <logic:equal name="processTaskView" property="assignmentTechnique" value="3">
              <bean:message key="bp.process.performerType.groupAllPerformer" bundle="bp.messages"/>
            </logic:equal>
            <logic:equal name="processTaskView" property="assignmentTechnique" value="4">
              <bean:message key="bp.process.performerType.resourceActor" bundle="bp.messages"/>
            </logic:equal>
            <logic:equal name="processTaskView" property="assignmentTechnique" value="5">
              <bean:message key="bp.process.performerType.resourceGroupAny" bundle="bp.messages"/>
            </logic:equal>
            <logic:equal name="processTaskView" property="assignmentTechnique" value="6">
              <bean:message key="bp.process.performerType.resourceGroupAll" bundle="bp.messages"/>
            </logic:equal>
            <logic:equal name="processTaskView" property="assignmentTechnique" value="7">
              <bean:message key="bp.process.performerType.stepPerformer" bundle="bp.messages"/>
            </logic:equal>
          </td>
        </tr>
        <logic:equal name="processTaskView" property="type" value="6">
          <tr> 
            <td class="label" width="30%"><bean:message key="bp.process.processTask.subprocessName" bundle="bp.messages"/></td>
            <td class="labelField" width="70%">
              <logic:greaterThan name="processTaskView" property="subprocessOid" value="0">
                <bean:write name="processTaskView" property="subprocessName"/>
              </logic:greaterThan>
              <logic:lessEqual name="processTaskView" property="subprocessOid" value="0">
                &nbsp;
              </logic:lessEqual>
            </td>
          </tr>
        </logic:equal>
        <logic:notEqual name="processTaskView" property="type" value="12">
          <tr> 
            <td class="label" width="30%"><bean:message key="bp.process.processTask.priority" bundle="bp.messages"/></td>
            <td class="labelField" width="70%">
              <html:radio name="bpProcessTaskForm" property="priority" value="1"/>
              <bean:message key="bp.process.processTask.priority.high" bundle="bp.messages"/>
              &nbsp;
              <html:radio name="bpProcessTaskForm" property="priority" value="2"/>
              <bean:message key="bp.process.processTask.priority.medium" bundle="bp.messages"/>
              &nbsp;
              <html:radio name="bpProcessTaskForm" property="priority" value="3"/>
              <bean:message key="bp.process.processTask.priority.low" bundle="bp.messages"/>
            </td>
          </tr>
          <tr> 
            <td class="label" width="30%"><bean:message key="bp.process.processTask.estimatedCycleTime" bundle="bp.messages"/></td>
            <td class="labelField" width="70%">
              <html:text name="bpProcessTaskForm" property="estimatedCycleTime" size="5" maxlength="5"/>
              &nbsp;
              <html:select name="bpProcessTaskForm" property="estimatedCycleTimeType" size="1">
                <html:option key="bp.process.type.workingHours" value="0" bundle="bp.messages"/>
                <html:option key="bp.process.type.clockHours" value="1" bundle="bp.messages"/>
                <html:option key="bp.process.type.workingDays" value="2" bundle="bp.messages"/>
                <html:option key="bp.process.type.calendarDays" value="3" bundle="bp.messages"/>
              </html:select>
            </td>
          </tr>
        </logic:notEqual>
        <logic:equal name="processTaskView" property="type" value="12">
          <html:hidden name="bpProcessTaskForm" property="estimatedCycleTime"/>
        </logic:equal>
      </table>
      <div class="pageButtonWrap" align="right">
        <input type="button" name="resetData" class="pageButton" 
          onClick="doReset(this.form);" 
          value='<bean:message key="button.reset" bundle="bp.messages"/>'>
        &nbsp;
        <input type="button" name="cancelData" class="pageButton" 
          onClick="doCancel(this.form);" 
          value='<bean:message key="button.cancel" bundle="bp.messages"/>'>
        <input type="button" name="saveData" class="pageButton" 
          onClick="doSave(this.form);" 
          value='<bean:message key="button.save" bundle="bp.messages"/>'>
      </div>
    </td>
  </tr>
</table>
</html:form>
